<?php
namespace app\backstage\logic;
class Log
{
    /*日志记录*/
    public function writeLog($params)
    {
        $Log = \think\facade\App::model('Log');
        return $Log->insertRecord($params);
    }

    /*日志列表数据获取*/
    public function getList($params)
    {

        $field = 'id,uid,account,request_mode,request_param,response,create_time,last_login_ip,path';

        $condition[] = ['account', 'eq', 'require', 'account'];
        $where = buildQueryCondition($condition, $params);

        if( isset($params['field']) ){
            $orderBy = [ $params['field'] => $params['order'] ];
        }else{
            $orderBy = ['id' => 'DESC'];
        }

        $Log   = \think\facade\App::model('Log');
        $list  = $Log->getList($where, $field, $params['page'], $params['limit'], $orderBy);

        $result['count'] = $Log->getTotalNumber($where);
        $result['list']  = $list;

        return $result;
    }

}